[AccessD] Open Database Method

A.D.TEJPAL adtp at hotmail.com
Wed Sep 13 09:30:47 CDT 2006


Jeremy,

    Your subroutine, slightly modified as shown below, was tested on Access 2K as well as 2K3. There was no problem. Modifications pertain to:
    (a) Statement (A) - workspace qualifier has been provided. It would work even otherwise, but since you have taken the trouble of specially creating one, it has been used.
    (b) Spelling correction in statement (B)

    Note - OpenDatabase method does not open the target db. It provides a pointer, through which, you can act upon the properties & methods available to CurrentDb object in the target db.

Best wishes,
A.D.Tejpal
---------------

Sample sub-routine
=================================
Sub TestThis()
    Dim wrkJet As DAO.Workspace
    Dim db As DAO.Database
    Dim sDB As String
    
    sDB = "C:\Test\Test.mdb"
    
    Set wrkJet = CreateWorkspace("wrkSpace", "admin", "", dbUseJet)
    Set db = wrkJet.OpenDatabase(sDB, True)    ' (A)
   
   Debug.Print db.Name
   Debug.Print db.TableDefs.Count
   
    Set db = Nothing
    Set wrkJet = Nothing        ' (B)
End Sub
=================================

  ----- Original Message ----- 
  From: Jeremy Toves 
  To: AccessD 
  Sent: Tuesday, September 12, 2006 01:30
  Subject: [AccessD] Open Database Method


  I hit a snag with a process I'm putting together.  I'm trying to use the OpenDatabase method in an Access 2000 database to open a second Access 2000 database so that I can enumerate indices.  I want to delete indices and reindex on demand from the first database.  I'm getting an error that the database is an unrecognized format.  I can open the 2nd database without problem if I go to it directly.  
     
  Here is the code I'm using.  Ideas?  Has anyone done this before?
     
  Thanks,
  Jeremy
     
      Sub TestThis()
      Dim wrkJet As DAO.Workspace
      Dim db As DAO.Database
      Dim sDB As String
      
      sDB = "C:\Test\BackEnd.mdb"
      
      Set wrkJet = CreateWorkspace("wrkSpace", "admin", "", dbUseJet)
      Set db = OpenDatabase(sDB, True)
     
        Set db = Nothing
      Set wrkject = Nothing
      
  End Sub


More information about the AccessD mailing list