Results 1 to 3 of 3

Thread: Open Database then close then Reopen Question?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 1999
    Location
    Brisbane, Qld, Australia
    Posts
    78

    Question

    Hi,

    I have the following code which opens a database when my application is first run:

    Function OpenDataBase(ByVal pDatabasName As String) As Boolean

    On Error GoTo OpenDataBaseError

    Set pWorkspace = Workspaces(0)
    Set pDatabase = pWorkspace.OpenDataBase(App.Path & "\" & pDatabasName, False, False)

    OpenDataBase = True

    End Function

    This opens the database and I have no problems here. I then later wish to close the database for maintenance and know that the following line closes the database:

    pdatabase.close

    Now my Question is: How do I reopen the database without it getting upset with pworkspace or any other complications?
    Any help is appreciated and thanks in advance.

    Mike


  2. #2
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696

    Talking

    Hi spawny

    As best as i can remember when you set the Pdatabase to the workspace, it stay's allocated to that untill you set the object to nothing. With that in mind you just need to do the Pdatabase.OpenDatabase command.

    I think this is right but i haven't used DAO for quite a while.

    Hope this helps

    Ian
    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

  3. #3
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    If pWorkspace and pDatabase is already instantiated from a previous call, the new SET statements will overwrite the existing contents with the new objects. If overwriting is a problem, then you have issues, otherwise don't worry about it

Posting Permissions

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



Click Here to Expand Forum to Full Width