| | Product Information Help and How-to Training Templates Support and Feedback Technical Resources Additional Resources | Warning: You are viewing this page with an unsupported Web browser. This Web site works best with Microsoft Internet Explorer 6.0 or later, Firefox 1.5, or Netscape Navigator 8.0 or later. Learn more about supported browsers.
Improve performance of an Access project
Depending on your computer's configuration and your working environment, there are several things you can do that may improve the performance of Microsoft Access or your Access project (.adp) (Microsoft Access project: An Access file that connects to a Microsoft SQL Server database and is used to create client/server applications. A project file doesn't contain any data or data-definition-based objects such as tables and views.) file. Improve the performance of an Access project
In a client/server application, the general rules of thumb for reducing network traffic and optimizing application performance are:
-
Do your data processing work on the server.
-
Minimize roundtrips to the server to access the data.
-
Limit the data you retrieve from the server.
Understanding OLE DB and the client/server environment
An Access project uses OLE DB to connect and communicate with a Microsoft SQL Server database. Microsoft designed the OLE DB (OLE DB: A component database architecture that provides efficient network and Internet access to many types of data sources, including relational data, mail files, flat files, and spreadsheets.) architecture to work efficiently in a client/server environment.
When you access data through a form or datasheet, OLE DB retrieves an updateable snapshot (updateable snapshot: A type of recordset that works efficiently in a client/server environment by caching data on the client and minimizing round trips to the server to access and update data.)
recordset (recordset: The collective name given to table-, dynaset-, and snapshot-type Recordset objects, which are sets of records that behave as objects.) from the SQL server database (up to the maximum record limit (maximum record limit: To improve performance, you can specify the maximum number of records that will be retrieved from a Microsoft SQL Server database for a form or datasheet in an Access project.)) and caches the data on the client— making one roundtrip to the server. Access retrieves the data asynchronously, which means that you can continue to interact with Access while the data is being loaded. When you work with the data on the form or datasheet, whether browsing, filtering, sorting, finding or updating data, you are working with the data that is cached on the client.
Processing data on the server
To process data on the server, you can use stored procedures, triggers, user-defined functions, and SQL SELECT statements. You can also sort data on the server before retrieving it.
Stored procedures are a precompiled collection of one or more SQL statements and optional control-of-flow statements that can accept parameters and are processed as a single unit by Microsoft SQL Server. A stored procedure resides in the SQL Server database. Because a stored procedure is compiled on the server when it is created, it executes faster than individual SQL statements. Because a stored procedure runs on the server, it takes advantage of the extra processing power of the server.
Triggers are a special kind of stored procedure that automatically execute when you update, insert, or delete data. Use triggers to enforce business rules and restrictions that are more complex than those defined with check constraints (constraint: A restriction placed on the value that can be entered into a column or a row. For example, values in the Age column cannot be less than 0 or greater than 110.). Unlike check constraints, triggers can reference columns in other tables. For example, a trigger can roll back updates that attempt to apply a discount (stored in a discounts table) to books (stored in a titles table) with a price of less than $10.
User-defined functions combine the best features of stored procedures and views into a single query that you can nest, pass parameters to, sort, and return values. In many cases, user-defined functions are a better alternative to stored procedures because you can return a single table of data or scalar value, hide the business logic and details of how that data or scalar value was created from the user, and simplify the complexity of your SQL statement syntax.
Sort records on the server by using a stored procedure, user-defined function, or SQL statement stored in the RecordSource property of a form or report (which is stored in the Access project, but executes on the server). Sorting records on the server is another way to take advantage of the extra processing power of the server.
Limiting data and property information retrieved from the server
As much as possible, limit the amount of data your application retrieves from the SQL Server database. Use views (view (object): In an Access project, a type of query that is a virtual table based on an SQL SELECT statement. For example, a view might contain only 3 out of 10 available columns in a join of two tables, in order to limit access to certain data.), stored procedures, user-defined functions, server filters, and SQL statement WHERE clauses to limit the data you or your users see in a form or datasheet. In general, avoid designing application scenarios where users browse the database in unrestricted fashion.
You can use the maximum record limit (maximum record limit: To improve performance, you can specify the maximum number of records that will be retrieved from a Microsoft SQL Server database for a form or datasheet in an Access project.) button or the MaxRecords property to limit the data you or a user can see in a form or datasheet.
You can also use server filters to limit records before they are retrieved from the database on the server, and filters to further limit records on the client. You can define a server filter in the ServerFilter property of a form or report. You can also optimize the performance of lists of values in Server Filter by Form (Server Filter By Form: A technique that uses a version of the current form or datasheet with empty fields in which you can type values you want the filtered records to contain. The data is filtered by the server before it's retrieved from the database.) and Filter by Form (Filter By Form: A technique for filtering data that uses a version of the current form or datasheet with empty fields in which you can type the values that you want the filtered records to contain.) windows by modifying the FilterLookup property to control the number of values displayed if the values are retrieved from either the server or client.
Disable automatic row fix-up if not required. After you update a record in a SQL Server 2000 database, Access normally resynchronizes the data to reflect the changed values. However, these operations require additional round trips to the server. You can disable row fix-up by setting the PerformResync property to No.
Disable pre-fetching of default values if not required. By default, when you display a form or datasheet, Access shows the default values in the new row of the datasheet and the form controls for new records on forms. This requires a round-trip to the server. You can disable the pre-fetching of default values by setting the Fetch Defaults property to No.
Optimizing the SQL Server database
The following are general guidelines for optimizing SQL Server database performance. For detailed information on improving SQL Server database performance, see the SQL Server documentation.
- Design tables without redundant data. A well-designed database is a prerequisite for fast data retrieval and updates.
- Enforce referential integrity (referential integrity: Rules that you follow to preserve the defined relationships between tables when you enter or delete records.), which preserves the defined relationships between tables when you add, update, or delete the rows in those tables by defining primary key and foreign key constraints in the related tables.
- Choose an appropriate data type for fields. This can save space in your database and improve join (join: An association between a field in one table or query and a field of the same data type in another table or query. Joins tell the program how data is related. Records that don't match may be included or excluded, depending on the type of join.) operations. When defining a field, choose the smallest data type or field size that's appropriate for the data in the field.
- Create indexes for fields that you sort, join, or set criteria for. You can make dramatic improvements in the speed of a query (query: A question about the data stored in your tables, or a request to perform an action on the data. A query can bring together data from multiple tables to serve as the source of data for a form, report, or data access page.) by indexing fields that are on both sides of joins, and fields that are used to set criteria for the query. Indexes, however, can slow down the speed of record insertions, updates, and deletes.
- Use indexed views in SQL Server 2000 databases. Indexed views can greatly improve the performance of views found in data warehouse or other decision support applications where large amounts of data are aggregated into sums and averages. An indexed view forces the view's results to be stored in the database, so statements that reference the view will have substantially better response times. When using indexed views, you should be aware that modifications to the base data are automatically reflected in the view, which may cause additional maintenance overhead.
- Add a timestamp field to your tables to improve performance of record deletions and updates, especially if your table contains many fields. SQL Server uses a timestamp field to indicate that a record was changed (not when it was changed) by creating a unique value field, and then updating this field whenever a record is updated. SQL Server uses the value in timestamp fields to determine whether a record has been changed before updating it. In general, a timestamp field provides the best performance and reliability, especially in a multiuser environment. Without a timestamp field, SQL Server must check all the fields in the record to determine if the record has changed, and this check can slow performance.
- Periodically compact your SQL Server database to save disk space and reorganize indexes and data for faster access.
Optimizing linked tables created in the Link Table Wizard
If the SQL Server database you are linking to is on another SQL Server, create a linked server (select Linked SQL on the first page of the Link Table Wizard). SQL Server, in most cases, will optimize joining operations.
Create an OLE DB data source that uses Transact SQL functions (select Transact SQL on the first page of the Link Table Wizard) if you are linking to Excel, text, or HTML files because the performance is generally better than creating a linked server.
Optimizing forms
When you design a form, determine the data and functionality needed, and then delay asking the server for this data and functionality until the information is requested by the user. For example, create a form so that it doesn't require data to be retrieved from the server during the form-opening process. For example, you can add a command button (command button: A control that runs a macro, calls a Visual Basic function, or runs an event procedure. This is sometimes called a push button in other applications.) to the form to load data on the form.
Use SQL UPDATE and DELETE statements with the appropriate WHERE clause to update or delete multiple records that meet the same criteria. This is more efficient than opening a recordset (recordset: The collective name given to table-, dynaset-, and snapshot-type Recordset objects, which are sets of records that behave as objects.) and performing the updates or deletions one record at a time.
Display fields that take a long time to retrieve data from the server, such as text (Text data type: In a Microsoft Access database, this is a field data type. Text fields can contain up to 255 characters or the number of characters specified by the FieldSize property, whichever is less.) and image (image data type: In an Access project, a variable-length data type that can hold a maximum of 2^31 - 1 (2,147,483,647) bytes of binary data. It is used to store Binary Large Objects (BLOBs), such as pictures, documents, sounds, and compiled code.) fields, only when requested. You can use the following techniques:
- Place text and image fields on a subform that uses the same record source (record source: The underlying source of data for a form, report, or data access page. In an Access database, it could be a table, query, or SQL statement. In an Access project, it could be a table, view, SQL statement, or stored procedure.). Access only retrieves the text or image values for the current record.
- Display the most important fields on a main form, and provide a button labeled "More Information" that opens another form containing other fields. Base the second form on a query (query: A question about the data stored in your tables, or a request to perform an action on the data. A query can bring together data from multiple tables to serve as the source of data for a form, report, or data access page.) that is passes as a parameter the primary key field on the main form.
- If your application is data-entry intensive, such as an order entry system, create a specific form for adding records that has the DataEntry property set to Yes. When you open the form to enter new data, Access doesn't display any existing records. This saves time because Access doesn't have to retrieve all the records from the server.
If a form based on a stored procedure or user-defined function that is a parameter query, use the Input Parameters property to supply the parameter values.
Optimizing reports
Instead of printing a long report, break up reports into smaller subsets of data by using views, stored procedures, user-defined functions, and SQL statements as your record source (record source: The underlying source of data for a form, report, or data access page. In an Access database, it could be a table, query, or SQL statement. In an Access project, it could be a table, view, SQL statement, or stored procedure.), or by using filters.
Use layout preview instead of print preview when you design your reports. You can take a quick look at the layout, which includes just a sample of the data in layout preview. When you are done working on the layout of the report, verify the data by opening the report in print preview.
You typically create and distribute reports on a schedule according to regular business cycles, such as weekly stock-level reminders, monthly sales reports, or quarterly financial statements. Create and distribute these reports as report snapshots (report snapshot: A file (.snp extension) that contains a high-fidelity copy of each page of an Access report. It preserves the two-dimensional layout, graphics, and other embedded objects of the report.) in a batch file. Users can use the Snapshot Viewer (Snapshot Viewer: A program that you can use to view, print, or mail a snapshot, such as a report snapshot. Snapshot Viewer 11.0 consists of a stand-alone executable program, a Snapshot Viewer control (Snapview.ocx), and other related files.) to view and print the reports. When your users need up-to-the-minute reporting, use grouped data access pages.
If a report is based on a stored procedure or user-defined function that is a parameter query, use the Input Parameters property to supply the parameter values.
Improve the performance of Access and your system
The following guidelines can help you optimize the performance of Access on your computer:
- If you're using databases that other users don't need to share, install Access and all your databases on your hard disk drive rather than on a network server.
- If you are the only person using a database, open the database for exclusive use; in the Open dialog box, click the arrow next to Open button, and then click Open Exclusive.
- Make more memory available by closing applications that you aren't using.
- Increase RAM on your computer. 40 MB of memory is recommended— 32 MB of memory plus an additional 8 MB of memory for Access.
- Don't use any of your RAM for a RAM disk.
- Periodically delete unnecessary files and empty your Recycle Bin, compact your databases, and then defragment your hard disk with the Microsoft Windows Disk Defragmenter. To run the Disk Defragmenter, click the Windows Start button, point to Programs, point to Accessories, point to System Tools, and then click Disk Defragmenter.
- In most cases, the default virtual memory setting used by Windows should perform optimally. However, in some situations, adjusting virtual memory parameters can improve performance. If you've already tried deleting unnecessary files and you still have a performance problem, try changing the default virtual memory setting in the following cases:
- You don't have much disk space available on the drive that is currently being used for virtual memory, and another local drive with space is available.
- Another local drive is available that is faster than the current drive (unless that disk is heavily used).
In these cases, you might get better performance by specifying a different drive for virtual memory.
You also might get better performance by specifying that the disk space available for virtual memory be at least 25 MB minus available RAM. For example, if your computer has 12 MB of RAM, you should specify at least 13 MB of virtual memory. You may want to specify more if you are running several large applications.
To change Windows virtual memory parameters, in Windows Control Panel, double-click the System icon, click the Performance tab, click Virtual Memory, and then click Let Me Specify My Own Virtual Memory Settings. Then specify a different hard disk, or enter a value in the Minimum box that is at least 25 minus your available RAM.
- If you have a wallpaper (full-screen background) bitmap on your Windows desktop, replace it with a solid color or pattern bitmap, or no bitmap at all.
- If you use a screen saver, use a blank screen saver or consider not using one at all.
- Eliminate disk compression software, or consider moving your databases to an uncompressed drive.
- To ensure optimal performance, use substitution fonts only if you need dual-font support to display all of your data.
Improve filter performance
If the lists in fields in the Filter By Form (Filter By Form: A technique for filtering data that uses a version of the current form or datasheet with empty fields in which you can type the values that you want the filtered records to contain.) window or Server Filter By Form (Server Filter By Form: A technique that uses a version of the current form or datasheet with empty fields in which you can type values you want the filtered records to contain. The data is filtered by the server before it's retrieved from the database.) window take too long to display or aren't displaying values from the underlying table, you can change their performance. For both types of windows, you can prevent the lists from displaying the underlying table's field values, or you can change the record limit that determines if the list displays a field's values.
Optimize Filter By Form performance for all tables, queries, and forms in the database or optimize Server Filter By Form performance for all forms
For Filter By Form, these settings affect all tables and queries, and all text box controls (control: A graphical user interface object, such as a text box, check box, scroll bar, or command button, that lets users control the program. You use controls to display data or choices, perform an action, or make the user interface easier to read.) whose FilterLookup property is set to Database Default. For Server Filter By Form, these settings affect all text box controls whose FilterLookup property is set to Database Default.
- On the Tools menu, click Options.
- Click the Edit/Find tab, and then set the Filter by form defaults according to the performance that you want to achieve.
- If the list of values takes too long to display, you can prevent the list from retrieving the unique values for each field by clearing the Records in local snapshot check box, which affects the Filter By Form window, and the Records at server check box, which affects the Server Filter By Form window.
- If lists aren't displaying the values from fields, check under Show list of values in to make sure that the appropriate boxes are selected, or try increasing the number in the Don't display lists where more than this number of records read box so that it's greater than or equal to the maximum number of unique values in any field in the underlying table or other record source.
Optimize Filter By Form or Server Filter By Form performance for a specific form
For each text box control (control: A graphical user interface object, such as a text box, check box, scroll bar, or command button, that lets users control the program. You use controls to display data or choices, perform an action, or make the user interface easier to read.) on a form, you can specify whether the values stored in the field appear on its list in the Filter By Form window or in the Server Filter By Form window.
- Open a form in Design view (Design view: A window that shows the design of these database objects: tables, queries, forms, reports, macros, and data access pages. In Design view, you can create new database objects and modify the design of existing ones.).
- Display the property sheet for any text box control.
- In the FilterLookup property box, set the property to the setting that will achieve the performance you want.
- If the list takes too long to display in the Filter By Form window or Server Filter By Form window, either set the FilterLookup property to Never, or set it to Database Default and then make the appropriate changes in the Options dialog box (Tools menu).
- If the list in the Filter By Form window or Server Filter By Form window isn't displaying the values that are stored in that field, or it's displaying only some of the values, make sure the FilterLookup property isn't set to Never. If the FilterLookup property is set to Database Default or Always, make the appropriate changes in the Options dialog box (Tools menu).
Improve find and replace performance
What is an index?
You can use an index to gain fast access to specific information in a database table. An index is a structure that orders the values of one or more columns in a database table, for example the last name (lname) column of the employee table. If you were looking for a specific employee by his or her last name, the index would help you get that information faster than if you had to search all the rows in the table.
The index provides pointers to the data values stored in specified columns of the table, and then orders those pointers according to the sort order you specify. The database uses the index much as you use an index in a book: it searches the index to find a particular value and then follows the pointer to the row containing that value.
In database diagrams, you can create, edit, or delete each type of index in the Indexes/Keys property page for a selected table. An index is saved in the database when you save the table that it is attached to, or when you save the database diagram in which that table appears.
As a general rule, you should create an index on a table only if the data in the indexed columns will be queried frequently. Indexes take up disk space and slow the adding, deleting, and updating of rows. In most situations, the speed advantages of indexes for data retrieval greatly outweigh these disadvantages. However, if your application updates data very frequently or if you have disk space constraints, you might want to limit the number of indexes.
Before creating an index, you must determine what columns to use and what type of index to create.
Index columns
You can create indexes based on a single column or on multiple columns in a database table. Multiple-column indexes enable you to distinguish between rows in which one column may have the same value.
Indexes are also helpful if you often search or sort by two or more columns at a time. For example, if you often set criteria for last name and first name columns in the same query, it makes sense to create a multiple-column index on those two columns.
To determine the usefulness of an index:
- Examine the WHERE and JOIN clauses of your queries. Each column included in either clause is a possible candidate for an index.
- Experiment with the new index to examine its effect on the performance of running queries.
- Consider the number of indexes already created on your table. It is best to avoid a large number of indexes on a single table.
- Examine the definitions of the indexes already created on your table. It is best to avoid overlapping indexes that contain shared columns.
- Examine the number of unique data values in a column and compare that number with the number of rows in the table. The result is the selectivity of that column, which can help you decide if a column is a candidate for an index and, if so, what type of index.
Types of indexes
Depending on the functionality of your database, you can create three types of indexes - unique, primary key, and clustered - in Database Designer.
Tip Although a unique index will help locate information, for the best performance results it is recommended that you use primary key or unique constraints instead.
Unique Index
A unique index is one in which no two rows are permitted to have the same index value.
Most databases prevent you from saving a table with a newly created unique index when there are duplicate key values in the existing data. Your database may also prevent the addition of new data that would create duplicate key values in the table. For example, if you create a unique index on the employee’s last name (lname) in the employee table, then no two employees can share the same last name.
Primary Key Index
A database table often has a column or combination of columns whose value uniquely identifies each row in the table. This column is called the primary key of the table.
Defining a primary key for a table in a database diagram automatically creates a primary key index that is a specific type of unique index. This index requires each value in the primary key to be unique. It also permits fast access to data when you use the primary key index in queries.
Clustered Index
In a clustered index, the physical order of the rows in the table is the same as the logical (indexed) order of the key values. A table can contain only one clustered index.
If an index is not clustered, the physical order of the rows in the table does not match the logical order of the key values. A clustered index usually provides faster access to data than does a nonclustered index.
Improve form and subform performance
There are several things you can do to make your forms run faster.
General tips
- Avoid overlapping controls.
- Don't sort records in an underlying query (query: A question about the data stored in your tables, or a request to perform an action on the data. A query can bring together data from multiple tables to serve as the source of data for a form, report, or data access page.) unless record order is important, especially with multiple-table queries.
- If the underlying record source (record source: The underlying source of data for a form, report, or data access page. In an Access database, it could be a table, query, or SQL statement. In an Access project, it could be a table, view, SQL statement, or stored procedure.) includes many records and you want to use the form primarily to enter new records, set the DataEntry property of the form to Yes so that the form opens to a blank record. If you open a form with all records showing, Access has to read each record before it can display the blank record at the end of the recordset.
- Close forms that aren't being used.
Tips for subforms
- Base subforms on queries rather than on tables, and include only fields from the record source (record source: The underlying source of data for a form, report, or data access page. In an Access database, it could be a table, query, or SQL statement. In an Access project, it could be a table, view, SQL statement, or stored procedure.) that are absolutely necessary. Extra fields can decrease subform performance.
- Index (index: A feature that speeds up searching and sorting in a table based on key values and can enforce uniqueness on the rows in a table. The primary key of a table is automatically indexed. Some fields can't be indexed because of their data type.) all the fields in the subform that are linked to the main form (main form: A form that contains one or more subforms.).
- Index any subform fields that are used for criteria.
- Set the subform's AllowEdits, AllowAdditions, and AllowDeletions properties to No if the records in the subform aren't going to be edited. Or set the RecordsetType property to Snapshot.
Improve list box and combo box performance
There are several things you can do to make your list boxes, combo boxes, and drop-down list boxes (drop-down list box: A control on a data access page that, when clicked, displays a list from which you can select a value. You cannot type a value in a drop-down list box.) run faster:
- Base the list box, combo box, or drop-down list box on a saved query (query: A question about the data stored in your tables, or a request to perform an action on the data. A query can bring together data from multiple tables to serve as the source of data for a form, report, or data access page.) instead of an SQL statement. On a form, if you use a wizard to create a list box or combo box, Access automatically sets the RowSource property of the control to an SQL statement. To change the RowSource property to a saved query, click the Build button
next to the RowSource property box. With the Query Builder window open, click Save on the File menu, and type a name for the query. When you close the Query Builder window, click Yes when Access asks if you want to update the property.
- Base the drop-down list box on a saved query instead of a table. On a data access page, if you use a wizard to create a drop-down list box, Access automatically sets the ListRowSource property of the control to the table you specified in the wizard. To retrieve rows from a query instead of a table, select the query name from the ListRowSource property box.
- In the query specified in the RowSource or ListRowSource property box, include only fields that are absolutely necessary. Extra fields can decrease performance.
- Index (index: A feature that speeds up searching and sorting in a table based on key values and can enforce uniqueness on the rows in a table. The primary key of a table is automatically indexed. Some fields can't be indexed because of their data type.) both the first field displayed in the combo box, list box, or drop-down list box and the bound field (if the fields are different).
- In combo boxes on a form, set the AutoExpand property to No if you don't need the fill-in-as-you-type feature.
- On a form, if the AutoExpand property for a combo box is set to Yes, the first displayed field should have a Text data type instead of a Number data type. In order to find a match in the list, Access converts a numeric value to text. If the data type is Text, Access doesn't have to do this conversion.
- On a form, if the bound field in a lookup combo box is not the displayed field:
- Don't create list boxes, combo boxes or drop-down list boxes based on data in a linked table (linked table: A table stored in a file outside the open database from which Access can access records. You can add, delete, and edit records in a linked table, but you cannot change its structure.) if the data won't change. It's better to import the data into your database in this case.
Note The Query Builder is not available in a data access page. Wizards are not available in a stand-alone data access page, or when you point a data access page to a database other than the one currently open. In both cases, you will have to create a list box or drop-down list box on your own.
Improve report and subreport performance
There are several things you can do to make your reports print faster.
Improve data access page performance
You can do several things to make your data access pages load faster in Page view (Page view: An Access window in which you can browse the contents of a data access page. Pages have the same functionality in Page view as in Internet Explorer 5.0 or later.) or in Microsoft Internet Explorer 5.01 with Service Pack 2 (SP2) or later.
General tips
- When using a data access page within Access, close all database objects that aren't being used. When using a data access page in Internet Explorer, close all windows that aren't being used.
- On data access pages that are used for data entry, set the DataEntry property of the page to True so that the page opens to a blank record.
- Index any fields that you sort, group, or filter on.
- Bind a data access page to an XML data file, so the page could get its data from a file located on the local client instead of having to access the database server.
Controls
- Avoid overlapping controls.
- Use bound span controls instead of text boxes to display any data that isn't updateable— for example, to display autonumbered values, values derived from expressions, and hyperlinks.
Security Use bound span controls or hyperlink controls with caution. Unauthorized users may be able to insert harmful HTML text into these controls. Processing this text without validation or modification could result in the loss of personal information or other data. To prevent the HTML text contained in a control from being rendered, encode the contents of the control.
Pictures and objects
- Use bitmaps and other graphic objects sparingly. Use black-and-white rather than color bitmaps.
Grouped pages
- Make sure the ExpandedByDefault property is set to False for the highest group level. Setting it to False for lower group levels will speed up other interactions after the page is opened.
- Make sure the DataPageSize group level property is set to a low rather than a high number, or is set to All. The lower the number, the faster the records are displayed.
- On a page that contains records with a one-to-many relationship, group records by table rather than by a field or expression.
- On a page that is based on tables with a one-to-many relationship, bind each section to a table rather than to a query. Access retrieves the records from a table only as it needs to display them on the page. With a query, Access retrieves all the records before it displays any records on the page. Use a query only when you want to limit the data used on the page, calculate aggregate values, or perform a task that's possible only in a query.
Read about making your Access project an ADE file to improve performance
If your Access project file contains Visual Basic for Applications (VBA) (VBA: A macro-language version of Microsoft Visual Basic that is used to program Windows applications and is included with several Microsoft applications.) code, saving your Access project as an .ade (ADE file: A Microsoft Access project (.adp) file with all modules compiled and all editable source code removed.) file compiles all modules, removes all editable source code, and compacts the destination Access project file. Your VBA code will continue to run, but it cannot be viewed or edited.
Your Access project file will continue to function normally— you can still update data and run reports. Additionally, the size of your Access project will be reduced due to the removal of the code, so memory usage is optimized, which will improve performance.
Saving your Access project file as an .ade file does not prevent changes to the design of the project. However, you will notice the following:
- The user interface for modifying or creating forms, reports, or modules will be disabled.
- The VBA References dialog box will not allow adding, deleting, or changing references to object libraries or databases.
- The source code will not be available.
- The importing and exporting commands will be disabled for forms, reports, or modules. However, tables, data access pages, views, stored procedures, database diagrams, and macros can be imported from or exported to non-ADE projects.
Considerations if you need to modify the design of forms, reports, or modules
Be sure to save a copy of your original Access project file. If you need to modify the design of forms, reports, or modules in an Access project file that you have saved as an .ade file, you must modify the original Access project, and then resave it as an .ade file.
You won't be able to open, convert, or run code in an .ade file in future versions of Access. The only way to convert an ade file to a future version will be to open the original Access project that the .ade file was created from, convert it to the later version of Access, and then save the converted Access project file as an .ade file.
Considerations before saving your Access project file as an .ade file
Some restrictions may prevent you from saving your Access project file as an .ade file:
- You must have password access to the VBA code if a password is defined.
- If your Access project references another Access project or add-in, you must save all Access projects and add-ins in the chain of references as .ade or .mde files.
About references and .ade files
If you try to create an .ade file from an Access project file or an add-in that references another Access project or add-in, Access displays an error message and doesn't let you complete the operation. To save an Access project that references another Access project as an .ade file, you must save all projects in the chain of references as .ade or .mde files, starting from the first project referenced. After saving the first project as an .ade or .mde file, you must then update the reference in the next project to point to the new file before saving it as an .ade file, and so on.
For example, if Project1.adp references Project2.adp, which references Project3.mda, you would proceed as follows:
- Save Project3.mda as Project3.mde.
- Open Project 2.adp and change its reference to point to the new Project3.mde.
- Save Project2.adp as Project2.ade.
- Open Project1.adp and change its reference to point to the new Project2.ade.
- Save Project1.adp as Project1.ade.
Read about compacting an Access project
Access combines compacting and repairing an Access file (Microsoft Access file: An Access database or Access project file. An Access database stores database objects and data in an .mdb file. A project file doesn't contain data and is used to connect to a Microsoft SQL Server database.) into a single process.
Compacting an Access file
If you delete data or objects in an Access database (Microsoft Access database: A collection of data and objects (such as tables, queries, or forms) that is related to a particular topic or purpose. The Microsoft Jet database engine manages the data.), or if you delete objects in an Access project (Microsoft Access project: An Access file that connects to a Microsoft SQL Server database and is used to create client/server applications. A project file doesn't contain any data or data-definition-based objects such as tables and views.), the file can become fragmented and use disk space inefficiently. Compacting the Access file makes a copy of the file and rearranges how the file is stored on your disk. Compacting a previous-version Access database won't convert it to Access 2002 - 2003 format.
Compacting optimizes the performance of both Access databases and Access projects. However, in an Access project, compacting does not affect database objects (database objects: An Access database contains objects such as tables, queries, forms, reports, pages, macros, and modules. An Access project contains objects such as forms, reports, pages, macros, and modules.)— such as tables or views— that reside in the Microsoft SQL Server database (Microsoft SQL Server database: A database in Microsoft SQL Server, it consists of tables, views, indexes, stored procedures, functions, and triggers.) instead of in the Access project itself.
Compacting has no effect on autonumbering in an Access project. However, in an Access database, if you have deleted records from the end of a table that has an AutoNumber field (AutoNumber data type: In a Microsoft Access database, a field data type that automatically stores a unique number for each record as it's added to a table. Three kinds of numbers can be generated: sequential, random, and Replication ID.), compacting the database resets the AutoNumber value; the AutoNumber value of the next record you add will be one greater than the AutoNumber value of the last undeleted record in the table.
Repairing an Access file
In most cases, Access detects whether an Access file is damaged when you try to open it and gives you the option to repair it at that time. If the current Access file contains a reference to another Access file that is corrupt, Access does not attempt to repair the other file. In some situations, Access may not detect that a file is damaged. If an Access file behaves unpredictably, compact and repair it.
Access can repair:
To help prevent corruption of Access files, follow these guidelines:
-
Compact and repair Access files regularly. You can specify that Access compact a file automatically when you close it.
-
Back up your Access files regularly.
-
Avoid quitting Access unexpectedly. For example, don't quit Access suddenly by turning off your computer.
-
If you are experiencing network problems, avoid using a shared Access database located on a network server until the problems are resolved. If possible, move the Access database to a computer where you can access it locally instead of over the network.
Repairing files after Access shuts down unexpectedly
If a serious problem occurs and causes Access to shut down, Access restarts, creates a copy of the file that was open, and names it filename_Backup.mdb or filename_Backup.adp, where filename is the name of the original file. If filename_Backup.mdb or filename_Backup.adp already exists, Access asks you to specify the name of the file. Access then attempts to compact and repair the original file.
|