Approach User Support homepage Approach User Support
Answers to Frequently Asked Questions about Lotus Approach
Examples LotusScripts
Example databases
Links to other Lotus Approach support services

[Return to contents]

Example LotusScript: Named Find Event

Last updated: before December, 1998

Paul Bent submitted the following script, saying:

At we were asked recently how to trigger a script when a named find is run from the list in the Action Bar.

Well there is no such event but you can hide the Action Bar and substitute a drop down list box containing the named finds. A script or macro can then run the find on data change in the drop down box.

Sub NewFindList
        Dim aFinds As Variant, UB As Integer, aFStr() As String, C As Integer
'We need an array of variants to get the named finds then a string array to set the list from
        aFinds = CurrentDocument.NamedFindSorts
        UB = Ubound(aFinds)
'Now we know how many so resize an array of strings. We need
'data type string to use the SetList method.
        Redim aFStr(UB)
'Load the strings into the array
        For C = 0 To UB
                aFStr(C) = aFinds(C)
'Populate a dropdown box list with the string array.
'The dropdown box is named FList and is unbound. When I created it I
'had to type z as the first list item because an empty list is not allowed at creation.
End Sub

To perform a named find as soon as it is selected, put the following script in the Change Script of the FList object:
Sub Change(Source As Dropdownbox)
If CurrentView.Body.Flist.Text = "" Then Goto ExitSub
CurrentWindow.NamedFindSort = CurrentView.Body.Flist.Text
End Sub

Alternatively, you perform the find by clicking a button (after you have selected the Named find in the dropdown box), by
inserting the following in the Click script of the button object:
Sub Click(Source As Button, X As Long, Y As Long, Flags As Long)
        If CurrentView.Body.Flist.Text = "" Then Goto ExitSub
        CurrentWindow.NamedFindSort = CurrentView.Body.Flist.Text
End Sub

[Return to contents]

© Copyright, JohnBrown, Trademarks, Disclaimer, Acknowledgements.