LOTUS CONNECTORS


Examples: SetValue method
This agent changes the value of a row and column specified by the user.

Uselsx "*LSXODBC"

Sub Initialize
 Dim con As New ODBCConnection
 Dim qry As New ODBCQuery
 Dim result As New ODBCResultSet
 Dim msg As String
 Set qry.Connection = con
 Set result.Query = qry
 con.ConnectTo("ATDB")
 qry.SQL = "SELECT * FROM STUDENTS ORDER BY LASTNAME"
 result.Execute
 result.LastRow ' Fetch all data into memory at start
 soughtrow = Inputbox _
 ("Which row do you want to change?", "Which row?")
 If soughtrow = "" Then
   Messagebox "No value entered for row",, "Bad row"
   Exit Sub
 End If
 If soughtrow < 1 Or soughtrow > result.NumRows Then
   Messagebox "Row out of range",, "Bad row"
   Exit Sub
 End If
 result.CurrentRow = soughtrow
 For i = 1 To result.NumColumns
   msg = msg & "  " & result.GetValue(i)
 Next
 soughtcolumn = Inputbox(msg, "Which column?")
 If soughtcolumn = "" Then
   Messagebox "No value entered for column",,  _
   "Bad column"
   Exit Sub
 End If
 If soughtcolumn = "" Or soughtcolumn < 1 _
 Or soughtcolumn > result.NumColumns Then
   Messagebox "Column out of range",, "Bad column"
   Exit Sub
 End If
 newValue = Inputbox$("Enter new value", "SetValue", _
 result.GetValue(Cint(soughtcolumn)))
 If newValue = "" Then
   Messagebox "No value entered"
   Exit Sub
 End If
 Call result.SetValue(Cint(soughtcolumn), newValue)
 result.UpdateRow
 result.Close(DB_CLOSE)
 con.Disconnect
End Sub

See Also