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: Fill Field No.1

Last updated: before December, 1998

Sub FillField
        
'This script was written by John Brown (of the Approach Users Mailing List)
'It fills a Numeric field with an incremental series of numbers
' eg 1, 2, 3, ... or 3, 6, 9 ... or 10, 7, 5, ...
'
'To use, create a new sub in the Script editor and paste the script over the
'default script contents. Then modify those lines of the script indicated my
'comments
        
        Dim Num As Integer
        Dim Inc As Integer
        Dim Counter  As Integer
        
        Num = 1    'This line sets the starting number (change as desired)
        Inc = 1    'This line sets the increment (change as desired)
        
        Counter = 0
        
        Dim rs As New ResultSet
        Dim C As New Connection
        Dim Q As New Query      
        
        If C.ConnectTo("dBASE IV") Then
                Set Q.Connection = C    
                
' In the next line set the path and filename of your .dbf file (retain the quotes)
                
                Q.Tablename = "C:\_DATA\scm\ascm\ascm6.dbf"
                Set rs.Query = Q
                If (rs.Execute)Then
                        Call rs.FirstRow
                        Do Until Counter = rs.NumRows
                                
'In the next line replace "PersonID" with your the name of your Numeric field
                                
                                Call rs.SetValue( "PersonID", Num)
                                rs.UpdateRow
                                Num = Num + Inc
                                Counter = Counter +1
                                If Counter < rs.NumRows Then Call rs.NextRow
                        Loop
                End If
        End If
        CurrentDocument.Window.Refresh
        Messagebox "Done!", 0, "FillField Script"
End Sub 

[Return to contents]

© Copyright, JohnBrown, Trademarks, Disclaimer, Acknowledgements.