Updating all the documents in a database
Posted on 2003-03-17
I have a database that I use for keeping track of all my tasks and projects.
It has a field in it for the date that tasks or jobs are due, called "Deadline", and one for today's date that it gets from @now. Also it has a field for "Days to go" ie the difference between the two from the formula (Deadline-Today)/86400. The form is set to "automatically refresh fields".
The problem is that after time, the values shown are wrong because todays date has changed. If I open each document, the field is not recalculated, but if I click on any field, it is. If I save the document when closing it, the "days to go" is then correct. But doing this on all the documents in the database is not practical.
So I'd like a script that opens each document in turn and then saves it, after doing something to cause the fields to be refreshed. It would preferably run from a button in the view. So far I have a button with the following script:
Sub Click(Source As Button)
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Set db=New NotesDatabase("","JobsRevised.nsf")
Set view=db.GetView("All summaries and tasks")
Do Until doc Is Nothing
Call doc.Save( True, True )
Messagebox ("Completed updating days to go")
It looks good to me, but it doesn't work. Can anyone fix it?