Modify The View Selection Criterion through a Button

I'm generating a dash board kind of report and would like to take different cuts depending upon month and fortnight - the dash board is in a Lotus Form. I would like to program the selection formula of different views used to generate the dash board. with a help of a button script. like If I click January, all 26 views selection formula should change to show only January document etc..I have taken a code from Notes help but it only works on current view - I'm not very good at scripting pls help thanks
Sub Click(Source As Button)
	Dim db As NotesDatabase
	Dim ws As New NotesUIWorkspace
	Dim uiview As NotesUIView
	Dim view As NotesView
	Dim formula As String
	formula = "SELECT (@Modified > [" & (Date - 7) & "])"
	Set view= db.Getview ("($Utilization - Americas1Total KoC-Mgr)")
	view.SelectionFormula = formula
End Sub

Open in new window

Who is Participating?
Sjef BosmanGroupware ConsultantCommented:
This is quite some Notes abuse that you're up to. Furthermore, it generates a LOT of activity on the server. I'll explain why this is not the way to restrict a view to a specific set of documents. A view in Notes is (usually) the same for everybody. A view contains data, actually, so if that data is manipulated, it will be noticed by everybody who uses that view. It can take quite some time to rebuild a view.

The better ways to make single-shot overviews of the documents in a Notes database:
- you can categorize documents, per year, per month, etc., all in a standard view
- you can use @SetViewInfo, to filter the view (might take some time to, but it doesn't change the view)
- you can use db.Search or db.FTSearch, to search a view and put the documents found in a folder, for inspection
You need to refresh all the views after changing the formula.

I hope this helps !
PrashantbhatnagarAuthor Commented:
When I use attached script I get object veriable not set error.
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

PrashantbhatnagarAuthor Commented:
Thanks for your advice Jef - I used @DBlookup to pull the required data from the categorized view based on Months. Its working fine with out any problem.
Sjef BosmanGroupware ConsultantCommented:
Does that mean that you removed the code above and you handle the problem differently?
PrashantbhatnagarAuthor Commented:
Yes - I used a Form to design the dashboard - I have put a Month selection field on the form - the other fields use DBlookup to select data from the categorized views based on months - I compare the value of months and pull the data in the dashboard. This is how it works...
This provides flexibility to users to see the Dashboard as per the month selected by them&.

Sjef BosmanGroupware ConsultantCommented:
Okay, so no embedded views any more. The consequence is that there might be a lot more processing involved... Sometimes, it is the only acceptable way.

Let's hope it works for you!!
I've requested that this question be deleted for the following reason:

No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Not enough information to confirm an answer.

If you feel this question should be closed differently, post an objection and a moderator will read all objections and then close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

Experts-Exchange Auto Deleter
Sjef BosmanGroupware ConsultantCommented:
IMHO my answer (ID: 24269730) helped the most, telling Asker that the the path taken wasn't very a promising one, at all. Up to your discretion to deal with this Question.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.