Share via


ProjectName Property [Access 2003 VBA Language Reference]

You can use the ProjectName property to specify or determine the name of your Microsoft Access Application object.

Setting

The ProjectName property is a string expression that's the name of your Microsoft Access Application object. You can't set the ProjectName property to the name of an existing class of objects, for example, "application," "form," or "report". If you convert a database with a name that is the same as that of an existing class of objects, Microsoft Access will append an underscore to the name to prevent naming conflicts. For example, if the database you are converting is named "Application", the database will have a project name of "Application_".

You can set the ProjectName property on the General tab of the ProjectName - Project Properties dialog box (available by clicking ProjectName Properties on the Tools menu in the Visual Basic IDE) or by using the SetOption method in Visual Basic. For example:

Application.SetOption "Project Name", "MyAccessProject"
		

Remarks

When you create a new database, Microsoft Access sets the ProjectName property to the database file name without the ".mdb" extension. Changing the database file name has no effect on the existing ProjectName property setting.

When you set the ProjectName property, the name of your Application object appears in the References dialog box, available in the Module window by clicking References on the Tools menu.

When you change the setting of the ProjectName property, your project will no longer be in a compiled state. To recompile the project, you must close and reopen your database and then click Compile And Save All Modules on the Debug menu.

From another application, such as Microsoft Excel, you can use the project name as part of the fully qualified name of an item in a Microsoft Access project by using the syntax projectname**.Application.Forms**!formname. For example, to refer to the LastName field on the Employees form in the Northwind sample database from Microsoft Excel, you set a reference to the Northwind database and then use the following reference:

Dim strLstName As String
strLastName = Northwind.Application.Forms!Employees!LastName
		

You can create a reference to a Microsoft Access database by selecting the project name (the Application object) in the References dialog box, available in the Module window by clicking References on the Tools menu. Once you select the project name, it also appears in the Project/Library list in the Object Browser.