Questions about displaying a view by username

I created a view to display private content by username. In view’s initialize event I added the following scripts:

Dim session As New NotesSession

Dim db As NotesDatabase

Dim view As NotesView

Dim formula As String

Dim doc As NotesDocument

Set db = session.CurrentDatabase

Set view = db.GetView("myview")

formula = "Select Form='myform'&UserName='"+session.UserName+"'"	

view.SelectionFormula=formula

Call view.refresh

The Scripts only worked when I opened the view twice.I created an action to check my code.The action’scode is as following:

Dim ws As New NotesUIWorkspace

Dim uiview As NotesUIView

Dim view As NotesView

Set uiview = ws.CurrentView

Set view = uiview.View

Messagebox view.SelectionFormula

When I opened the view at the first time,the view.SelectionFormula looked right as content wasn’t what I expected.When I opened the view the second time,everything was ok.Now problem is after user A opened the view, user B will see user A’s content when he open the view. Please help me.

Subject: Questions about displaying a view by username

You’ll neeed a private on first use, or put the documents you want into a folder that is displayed to the user.

UserName cannot be used successfully on a server view or you buld a view and show single category selected by username.

search this forum for username and view for more details.

Subject: RE: Questions about displaying a view by username

Thank you for your answer.I have resolved the problem with rebuilding the view in postopen event. Now I have another question. The method “NotesUIWorkspace.ViewRebuild” can’t excute in a frameset.What can I do?