Create a New Personal Geodatabase (VB)


This sample will demonstrate the steps needed to create a new personal geodatabase stored in an .mdb file.

How to use:
  1. Paste the code into your VB or VBA Application.
  2. Call the function from within your application.
'' createAccessWorkspace
'' NOTE:
''   Location does not have to contain ending '\'
''   Name should not contain .mdb extension
Public Function createAccessWorkspace(Location As String, Name As String) _
           As esriCore.IWorkspaceName

  On Error GoTo EH
  Set createAccessWorkspace = Nothing
  ' create the Access Workspace factory
  Dim pWorkspaceFactory As IWorkspaceFactory
  Set pWorkspaceFactory = New esriCore.AccessWorkspaceFactory
  Dim pWorkspaceName As esriCore.IWorkspaceName
  Set pWorkspaceName = pWorkspaceFactory.Create(Location, Name, Nothing, 0)
  Set createAccessWorkspace = pWorkspaceName
  Exit Function
    MsgBox Err.Number, vbInformation, "createAccessWorkspace"
End Function