Hi everyone,
As a bit of a newb to Notes dev, maybe everyone here can tell me a better way of doing what I’m trying to achieve.
I have a view in which I only want to display entries if the ‘Completed’ field = “No”. I made some simple code and put it in the PostOpen event, as I couldn’t see any other way of only displaying the relevant entries.
Here’s the code I have:
Sub Postopen(Source As Notesuiview)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim selection As String
Dim collection As NotesDocumentCollection
Set db = session.CurrentDatabase
selection = "@Contains(Completed; ""No"" )"
Set collection = db.Search(selection,Nothing, 0 )
Call collection.PutAllInFolder("Not Completed",True)
End Sub
There wasn’t a problem with this, it worked fine - the first time I opened the view. Everytime I’ve opened the view since, every entry is displayed!
Is this something to do with PostOpen, or is there somewhere else I can put my code in order for it to work everytime?
TIA,
Nicola
Subject: View PostOpen event
Nicola…if i understand your query you need to display documents with “Completed” field as “No”.If this is the case why dont you use simple view selection formula.It would be Select form = “Yourformname” & Completed = “No”.Create a view and place the above selection formula in “View Selection”.Or are you trying to do something else.??
Subject: RE: View PostOpen event
Hi,
Yes thanks, that’s exactly what I wanted to do, however, I put the code in the View selection as suggested, and I now receive a completely blank view! I’m a bit confused as to why.
Thanks again,
Nicola
Subject: View PostOpen event…solved!!!
Oops!
I was first trying the following:
Select form = “Main” & Completed = “No”
which gave me a blank view, so then tried
Select Completed = “No”
and it now works perfectly!
Thanks both of you for your help!
Nicola
Subject: RE: View PostOpen event…solved!!!
Yes that would give you results.But the formula you wrote might give you problems in future.It would be better if you use form tag with the selection formulla.You must be using a form to compose and save the documents.You can use that in your form tag.If you wont use this, the view might display documents with another form which has a “Completed” field set to “No”.So this filters out only those document with the specified form and field value.
Subject: RE: View PostOpen event…solved!!!
Ah, ok I didn’t know that.
It probably won’t be a problem in this db though, as it is only small and just has one form.
Thanks for your input though! I will keep it in mind in the future.
Nicola
Subject: RE: View PostOpen event
Don’t use a folder for this. Use a view. Set the view selection formula to SELECT Completed = “No”. Not necessary to use Postopen event for a simple selection like this.