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: Go back to the last thing that the user was using

Last updated: 10 Nov 2002

David Legge writes: First cut and paste this declaration into Global declarations. Then follow the instructions in the first set of comments
- they come out green in the IDE (Script editor)

Class ViewCollection
' coded by Dave Legge, 2001
' ---------------------------------------------
' HOW TO DO IT
' 1  Declare global variable 
'    Dim Views As Viewcollection
' 2  In (Globals.initialise) or in your files documentwindow.openwindow event add the line
'    Set Views = New Trailcollection
' 3  in yourdocument's Documentwindow.Viewswitch event place 
'    Call Views.moveon ToView  
'    NOTE:  up to Apr 9.7 ToView and FromView parameter Declarations are reveresed in the IDE!
'           it ought to be Call Views.moveon FromView !!!!!
' 4  From your button.click  or worksheet.cellgetfocus event
'    Call Views.moveBack 
' ---------------------------------------------
trail As collection
goingback As Integer
Sub New
' Print "Calling TrailCollection.New"
goingback = False
Set trail = New collection
' On Event Viewswitch From currentdocument.DocumentWindow Call moveonevent
End Sub
Sub moveon ( Fromview As VIEW)
If Not goingback Then 
trail.add fromview      'Push View onto collection
' Print "Push: "; fromview.name 
End If 
goingback = False
End Sub 
Sub moveback
If trail.count <> 0 Then
goingback = True
' Print " Pop "; Trail(Trail.count-1).name, trail.count 
Set CurrentWindow.ActiveView = Trail(Trail.count-1) ' Top one
trail.remove(Trail.count-1) ' Pop it
Else
Messagebox "At start of Trail" & Chr$(10) & "Can't go back any further",64,"BACK"
End If
Yield           ' Let windows take you there before proceeding
goingback = False 
End Sub
End Class

[Return to contents]

© Copyright, JohnBrown, Trademarks, Disclaimer, Acknowledgements.