On Event?

This appears to be unreliable with new documents:

Sub Initialize

Dim ws As New NotesUIWorkspace

Dim ui As NotesUIDocument



Set ui = ws.currentdocument



On Event QuerySave From ws.currentdocument Call fm_QuerySave

End Sub

This takes place in my script library.

Should I be handling the situation differently?

TIA,

Collin

Subject: On Event ?

Sub Querysave(Source As Notesuidocument, Continue As Variant)

Call fm_QuerySave

End Sub

Subject: RE: On Event ?

That works, but …I’d like my library to be implemented without having to modify the original form. Hence capturing the Event.

Subject: RE: On Event ?

Hmmm - In that case, I’m not sure what to suggest.

Is the form unavailable to you for editing? Or are you trying to do some general purpose coding that will apply to all forms, or something like that?

If the form is unavailble for editing but a subform is, you can always call the function from a subform instead as long as you know the subform will always be loaded in the document.

Subject: RE: On Event ?

It’s for a general-purpose piece of code that is not associated with any particular form.

Subject: RE: On Event ?

And how, pray, is the code supposed to run if it has no “load and run me” context? On Event works IF the code is loaded – say, in the form Globals. If it’s just lying there, dormant, in a script library, then it will never run. There was a great article in what was then Iris Today (then LDD Today, then, poof!!!) that did pretty much exactly what you’re describing. The point of the article was OOP in LotusScript, but the example was an extended Notes UI document class where all of the form events were overriden using On Event. (The article was by Andre Guirard. If anyone knows where it might be living, the URL would be much appreciated.)

Subject: RE: On Event ?

Your response is nonsense. Of course a library requires a “use” statement at some level.What I wanted to do was put all the event-handling in place with only the Use statement. It appeared to be unreliable on new documents, so I had to add some code to the QuerySave event.

Subject: RE: On Event ?

How/where were you running the code?

Subject: RE: On Event ?

How/where were you running the code?That was stated in the initial post:

"Sub Initialize

Dim ws As New NotesUIWorkspace

Dim ui As NotesUIDocument

Set ui = ws.currentdocument

On Event QuerySave From ws.currentdocument Call fm_QuerySave

End Sub

This takes place in my script library."

Subject: RE: On Event ?

I guess what I was asking was whether or not you are certain that the Sub Initialize in your library is taking place in the Initialize event of the form – the overwrite should happen, but is it actually happening?

Subject: RE: On Event ?

That’s the problem. It appears to always work on existing documents but is unreliable on new documents.