Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Apr 2005
    Location
    Plovdiv
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    open database (Access 2000)

    I am using a function to open another database called OpenHospital.When i use it alone, it is ok,but when
    i use it within another function then i get the error that the databse is used by another user which i
    cannot understand.is there any simpler way to open another database?

    Public Function OpenHospital()
    Dim appAccess As Access.Application
    Set appAccess = CreateObject("Access.Application.9")
    appAccess.OpenCurrentDatabase "C:beHospital.mdb"
    appAccess.Visible = True
    appAccess.UserControl = True
    appAccess.DoCmd.RunCommand acCmdAppMaximize 'This maximizes the window
    End Function


    Function FncAutoexec()
    DoCmd.OpenForm " referencecollection"
    OpenHospital
    DoCmd.Quit
    End Function

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: open database (Access 2000)

    In general, it's not a good idea to open another database and make it visible. What do you want to accomplish?

  3. #3
    2 Star Lounger
    Join Date
    Apr 2005
    Location
    Plovdiv
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: open database (Access 2000)

    In the OnOpen event the database process the tables of our departments.i just wanted to automate the process.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: open database (Access 2000)

    You don't need to open another database in the interface in order to process tables, you can either use DAO and open a Database object in code only, or link the tables in the current database, you can then process the data as if they were present in the current database.

  5. #5
    2 Star Lounger
    Join Date
    Apr 2005
    Location
    Plovdiv
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: open database (Access 2000)

    Thank you vrey much.It is very smart what you have suggested and i will certainly make us of it.However,after finishing the processing i will have to open the database
    anyway,in order ot look at the resultsSo i will have to leave the first database and open the already processed database..If this is dificult then i will leave it, your advice
    will do for just to process the database, and i could open it later on manually.Thank you once again.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: open database (Access 2000)

    If you want to leave the current database and open the other one, you don't have to create an Access.Application object. You can simply use

    OpenCurrentDatabase "C:beHospital.mdb"

    This will automatically close the database from which you run this code. As a consequence, all code after the line with OpenCurrentDatabase will not be executed any more.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •