Working with a "native grid" in a Notes form

This is a useful script function when working with a "grid" where you can calc values and/or get and set values.

This is a useful script function when working with a "grid" where you can calc values and/or get and set values in several types of applications using a "grid." This code works in a Notes client but it is very easy to use the same scheme in JavaScript.

1. Create a table with four columns and four rows. Put a field in each cell and name the fields A,B,C,D.

2. Create a table with four columns and one row. Copy and paste the fields in the top table into the table. The first row starts with A_1 and the last row with A_4. The next column is B_1...etc. This one only works when you make a copy of the row in the top table. Otherwise, the names of the fields are A_1_1, B_2_2 and that will not work.

2a. Now you can hide the top table. However, do not remove the table. It is very useful if you want to change the properties for a field. You can do it in one place then copy and paste again.

3. Create an agent and paste the code into it. Then save the agent manually from the action menu and run once.

4. Create an action. Name it and from simple action, choose run agent.

You can not calc values in a very simple way in a grid. Write the values in the first three columns and run the agent by pressing the action button.

'Global declaration
Dim ColumnCounter(1 To 4) As String
Dim Uidoc as notesuidocument


Sub Initialize
Dim workspace As New notesuiworkspace
Dim i As Integer	

Set uidoc = workspace.currentdocument

Call setColumnNames

For i = 1 To 4
 Call setAndCalcFields(i)
Next i
End Sub



Sub SetColumnNames()
 ColumnCounter(1) = "A"
 ColumnCounter(2) = "B"
 ColumnCounter(3) = "C"
 ColumnCounter(4) = "D"
End Sub



Sub setAndCalcFields(row As Integer)
Dim x As Integer	
Dim FieldName As String
Dim sum As Double
On Error Resume Next
 For x = 1 To 3
  fieldName =	ColumnCounter(x) + "_" +Trim(Str(row))
  sum = sum + Cdbl(uidoc.FieldGetText(FieldName))
 Next x
  fieldName =	ColumnCounter(4) + "_" +Trim(Str(row))
  Call uidoc.FieldSetText(fieldName, Str(sum))
End Sub
This was first published in June 2001

Dig deeper on Domino Resources - Part 5

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.UK

Close