-
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
-
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
-
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