Force DB to open local

Hi

I would like to force a database to open locally. The database is opend from a databaselink i another database. The local database has a replicacopy on the server - and I can control wich database to open. I would like to force the local datbase to open.

Any help will be approciated

Thanks in advance

Oscar

Subject: Do it at the View -Force DB to open local

The order of events when opening a database (with a default view) is that the View’s events fire first and then the database. After successfully coming up with several scripts that would crash the Notes client every time at the DB level, I switched to the View level and found something that works. Now I will need to add this to all views or change the initial UI to a frameset with a set view that has the code.

Code:

'Notes Objects

Dim WS As NotesUIWorkspace

Dim UIDB As NotesUIDatabase



Dim CurrDB As NotesDatabase

Dim PostDB As NotesDatabase



Dim Flag As Boolean

'Get Handle to Notes Objects

Set WS = New NotesUIWorkspace

Set UIDB = WS.CurrentDatabase

Set CurrDB = UIDB.Database

'Check server

If CurrDB.Server <> "" Then

'Cannot use msg box - breaks context on next commands

	'Msgbox "You are currently working on the server not locally." + Chr(13) + "You will now be switched  to local to improve performance." , 0, "Working on wrong copy of application."

'Get handle to local replica using server replica ID and open

	Set PostDB = New Notesdatabase("", "")

	Flag = PostDB.OpenByReplicaID("", CurrDB.ReplicaID)

'Set bookmark on workspace to local to avoid in future

	Call WS.AddDatabase( "" , PostDB.FilePath)

'Open local

	Call WS.OpenDatabase( "", PostDB.FilePath, "", "", False, False )

'Close current UIView

	Call Source.Close		

End If

Subject: Force DB to open local

Using NotesDatabase.Server, you can see if the database is local or not. You can add that check in the Database Script’s PostOpen event.

If the Server is not “” then you are not using the local replica. You can then add code that will open up the local database and close the other one.

Ben Dubuc

Montreal, Canada

Subject: Force DB to open local - How

Benoit - any sample or suggestions on how to close and open?

Thanks!

Subject: RE: Force DB to open local - How

something like this?

If Not (db.server = “”) Then

Msgbox("Your running on the server - not allowed")

Exit Sub

End If

Subject: RE: Force DB to open local - How

I know how to trap for not being on server, but I have a very basic set of users who do not use the workspace so they have no way of switching to the local replica. I wanted to provide a programmatic way of doing this. There does not seem to be a method or property of the Workspace or UIDB to do this.

Any help is appreciated.