Developer FAQs - Application StartupThis page contains several FAQs on Application Startup using Access. |
When should you repair and compact a database and what do they do? |
|
How can I start Access using an alternative workgroup file for security? |
|
| |
|
What are command line options and how do you use them?
Keywords: Command Line
Posted November 18, 1996
You can automatically open a database, run a macro, or supply a user name or password when you start Microsoft Access by entering options on the command line.
For example, the following command line starts Microsoft Access, opens the Northwind Traders database for exclusive access, and runs the Add Products macro:
C:\ACCESS\MSACCESS.EXE NWIND.MDB /Excl /X Add Products
The following table lists the Microsoft Access 2.0 command-line options:
Option |
Effect |
<database> |
Opens the specified database. Include a path name if necessary |
/Excl |
Opens the specified database for exclusive access. To open the database for shared access in a multiuser environment, enter the command line without this option |
/Ro |
Opens the specified database for read-only access |
/User <user name> |
Starts Microsoft Access using the specified user name |
/Pwd <password> |
Starts Microsoft Access using the specified password |
/Ini <initialization file> |
Starts Microsoft Access using the options in the specified initialization file instead of the standard MSACC20.INI file. The initialization file must have the same entries as the standard MSACC20.INI file |
/Compact <target database> |
Compacts the database specified before the /Compact option and then closes Microsoft Access. To compact to a different name, specify a target database |
/Repair |
Repairs the specified database and then closes Microsoft Access |
/Convert <target database> |
Converts a 1.x database to a 2.0 database, with a new name and then closes Microsoft Access. Specify the source database before the /Convert option |
/X <macro> |
Starts Microsoft Access and runs the specified macro. Another way to run a macro when you open a database is to create an AutoExec macro |
/Cmd |
Specifies that what follows on the command line is the value that will be returned by the Access Basic Command function. This option must be the last option on the command line. You can use a semicolon (;) as an alternative to /Cmd |
The table below outlines the Access 95 command line options:
Option |
Effect |
database |
Opens the specified database. Include a path if necessary |
/Excl |
Opens the specified database for exclusive access. To open the database for shared access in a multiuser environment, omit this option |
/Ro |
Opens the specified database for read-only access |
/User user name |
Starts Microsoft Access using the specified user name |
/Pwd password |
Starts Microsoft Access using the specified password |
/Profile user profile |
Starts Microsoft Access using the options in the specified user profile instead of the standard Windows Registry settings created when you installed Microsoft Access. This replaces the /ini option used in previous versions of Microsoft Access to specify an initialization file. The Microsoft Access Developer's Toolkit contains tools and information on creating user profiles. For more information, click |
/Compact target database |
Compacts the database specified before the /Compact option and then closes Microsoft Access. If you omit a target database name following the /Compact option, the database is compacted to the original database name. To compact to a different name, specify a target database |
/Repair |
Repairs the specified database and then closes Microsoft Access |
/Convert rt target database |
Converts a database in an earlier version (1.x or 2.0) to a Microsoft Access 95 database with a new name and then closes Microsoft Access. Specify the source database before the /Convert option |
/X macro |
Starts Microsoft Access and runs the specified macro. Another way to run a macro when you open a database is to use an AutoExec macro |
/Cmd |
Specifies that what follows on the command line is the value that will be returned by the Command function. This option must be the last option on the command line. You can use a semicolon (;) as an alternative to /Cmd.For information on the Command function, click |
/Nostartup |
Starts Microsoft Access without displaying the startup dialog box (the second dialog box you see when you start Microsoft Access) |
/Runtime |
Starts Microsoft Access in run-time mode, which prevents database objects from being opened in Design view |
/Wrkgrp workgroup |
Starts Microsoft Access using the specified workgroup information information file file |
| |
|
How do you prevent the Autoexec macro from executing?
Keywords: Command Line
Posted November 18, 1996
Most custom applications will have an Autoexec macro that initializes the environment when a user opens the database. Sometimes it becomes necessary to prevent the execution of this macro in the course of debugging.
To prevent the Autoexec macro from running hold the shift key down when opening the database.
When should you repair and compact a database and what do they do?
Keywords: Compact Repair
Posted November 18, 1996
With use, the internal structure of a database can become fragmented, leading to wasted disk space which can result in poor performance. Additionally, databases may become corrupted. Corruption typically occurs when users reboot workstations, power goes out, disk drives go bad.
The usual practice is to Repair the database first and then Compact it.
Compacting a database does the following:
Also, To compact the database the following conditions must be met:
In Access 2.0 you open Access, but don't open any database. Click the File menu; one of the options is Repair, another is Compact; and each will prompt for a database name.
In Access 95 you open Access, but don't open any database. Click the Tools menu and then click the Database Utilities submenu; one of the options is Repair, another is Compact; and each will prompt for a database name.
What is the Access Service Pack and why do I need it?
Keywords: Service Pack
Posted November 18, 1996
The Service Pack fixes a number of irritating problems that causes an internal database flag that is used to determine the state of data in the database to be erroneously set, sometimes causing the error message "Couldn't open SYSTEM.MDA." In order to work around this problem, customers have to run the repair utility on the database, a process that can be lengthy for large databases. The problem does not cause damage to the database or data in it, but can be inconvenient. The Service Pack also includes updated OLE dynamic-link library (DLL) files that allow third-party OLE custom controls to run in Microsoft Access 2.0, updated Paradox, Btrieve, and xBASE ISAM drivers, and an updated Setup Wizard.
The Service Pack contains The Microsoft Jet database engine version 2.5. This is an updated version of the database engine that ships with Microsoft Access 2.0 and Microsoft Visual Basic version 3.0. The Microsoft Jet database engine has been modified to enhance database repair functionality and to correct the erroneous setting of an internal database flag that in some cases results in the error message "Couldn't open SYSTEM.MDA."
OLE 2.02 is also included and is a minor upgrade to the OLE libraries shipped with Microsoft Access 2.0. These new libraries are included primarily because third-party custom controls will expect to find these libraries installed. Developers using third-party controls or controls distributed by other Microsoft products should install these libraries. The new OLE libraries also correct problems with diminished system resources when printing reports containing embedded Microsoft Graph objects.
The Microsoft Access repair utility has been enhanced so that more databases can be repaired successfully. The enhancement enables the repair utility to traverse a table from beginning to end, and from end to beginning if needed, allowing the utility to recover data pages that could not be recovered before the enhancement. A data page can become damaged if the computer is turned off while a data pages contains changes that have not been saved.
Some of the problems encountered without using the Service Pack are listed below:
The Microsoft Jet database engine misinterprets the underscore or the percent sign. This causes the Jet database engine to pass an incorrectable name to the DB2 ODBC driver.
The Microsoft Jet database engine version 2.0 may erroneously leave an internal database flag set that in some cases results in one of the error messages stated above.
Or, a query based on an attached Btrieve table does not return any records in Microsoft Access version 2.0. This same query does return records correctly in Microsoft Access version 1.x.
In certain queries containing many-to-many join fields, Microsoft Access can choose an incorrect index when it interprets the query. Using the wrong index results in poor performance.
Trying to register such a control in Microsoft Access will cause the following error message:
Using a utility such as REGSVR.EXE or MSAREG.EXE will result in the error message:
This problem occurs only with queries for which all of the following conditions are true:
The error is caused by the query optimizer. Any changes made to the query or its underlying tables that cause Microsoft Access to change its query optimization strategy can either result in or resolve this error. Changes include adding criteria to the query, qding indexes to or removing them from underlying tables, adding rows to underlying tables, and then resaving the query, and so on.
How can I start Access using an alternative workgroup file for security?
Keywords: Workgroup Security
Posted November 18, 1996
There are a couple of ways to this in Access 2.0:
In Access 95, you can use the Workgroup Administrator to either create or join a new workgroup (*.mdw) file. You can then use command line options to open your database using this new workgroup file:
How can eliminate the menu bar when displaying a form?
Keywords: Menu Bar
Posted November 18, 1996
Just add "=1" to the Menu Bar property of the form being displayed.
What is an easy way to manage my startup forms?
Keywords: Startup Forms
Posted November 18, 1996
Typically, many application has a number of forms to be displayed on startup. One way to manage these forms is to create a local table which will contain the name of the form and the mode it should be opened in. You then can call a generic function to loop through the recordset and open all the forms:
The example below is usually called from the Autoexec function of the application:
Function StartupForms (szTblName As String) As Integer
''' Function: StartupForms
'''
''' Comments: This function loops through the startup table
''' and retrieves the form names and mode to open
''' then by.
'''
''' Arguments: szTblName - Name of table which contains list
''' of forms to open
'''
''' Returns: True or False
'''
''' Called by: Autoexec macro
'''
''' Keywords: OPEN STARTUP AUTOEXEC
'''
''' Date Developer Action
''' -------------------------------------------------------------------------
''' 8/01/96 Marty Wasznicky created
''' 8/17/96 Marty Wasznicky modified
On Error GoTo StartupForms_Err
Dim rstStartup As Recordset, iStartup As Integer
Dim dbCurrent As Database
Dim fldName As Field, fldMode As Field
Dim szProcName As String
szProcName = "StartupForms"
StartupForms = True
''' obtain list of forms to load at startup
Set dbCurrent = DBEngine(0)(0)
Set rstStartup = dbCurrent.OpenRecordset(szTblName, db_Open_Snapshot)
Set fldName = rstStartup!FormName
Set fldMode = rstStartup!Mode
''' Determine if any records exist in the form table
If Not rstStartup.BOF And Not rstStartup.EOF Then
'''Inilize status bar
rstStartup.MoveLast
gvReturn = SysCmd(SYSCMD_INITMETER, "Initializing...", rstStartup.recordcount)
iStartup = 1
''' Open all forms
rstStartup.MoveFirst
Do Until rstStartup.EOF
DoCmd OpenForm fldName, fldMode
''' Update status bar
gvReturn = SysCmd(SysCmd_UpdateMeter, iStartup)
iStartup = iStartup + 1
rstStartup.MoveNext
Loop
End If
StartupForms_Exit:
On Error Resume Next
gvReturn = SysCmd(SYSCMD_REMOVEMETER)
Exit Function
StartupForms_Err:
StartupForms = False
Call ErrMsg(Err, Error$, Trim$(szProcName))
Resume StartupForms_Exit
End Function
In Access 2.0, how do I hide the database window?
Keywords: Hide Database
Posted November 18, 1996
Unfortunately, there is no graceful way to hide the database window in Access 2.0. The only way to accomplish it is through the use of SendKeys. This can be called by your Autoexec function. An example follows:
Back to the FAQ Table of Contents
It's starting to smoke...Should I turn it off? |
Copyright© 1996-1999, Baarns Consulting Group, Inc. - All rights reserved. |