DBEngine.CreateWorkspace method (DAO)
Applies to: Access 2013, Office 2013
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: 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: 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. |
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.
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