Opening view using script

Hi

I am trying to write a script that gets the name of a view from a profile document then opens the view in the target frame. The issue is that whenever I open the DB the script runs but the view get opened in new frameset not in the the target frame. Following is the script that resides in the Queryopen of the form that I call in the the target frame.

Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant)
Dim sess As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Set db = sess.CurrentDatabase
Set view=db.Getview(“Admin”)
Set doc=view.Getfirstdocument()

If Not doc Is Nothing Then
Forall x In doc.NEW_TrackedFields
fieldvalue=doc.Getitemvalue(x)
If fieldvalue(0)=db.Filepath Then
viewname=doc.Getitemvalue(“DefaultView_”+Right(x,1))
Exit Forall
End If
End Forall
End If

Dim ws As New NotesUIWorkspace
Dim uidb As NotesUIDatabase
Set uidb = ws.CurrentDatabase
Call uidb.OpenView(viewname(0), ,False,True)
continue=False
End Sub

Please advise urgently

Thanks

Subject: You can try NotesUIWorkspace.SetTargetFrame, but I’m unsure the attempts will work in this context.

Normally you’d need to to set the target frame, and then open the view.

However, the QueryOpenDatabase may not be positioned where you can actually pull this off. The “Query” part sometimes means that the database hasn’t been opened yet … in which case, there’s no target out there to point to.

I remember having trouble with this.

You may need to move to the frameset, where you can select the frame being opened using @functions.