Bound Mode > Unbound Columns > Implementing unbound columns using cell access methods |
Using Recordset clones is the preferred way to handle the UnboundColumnFetch event. However, if the list is bound to a data control that does not support clones, such as the Microsoft Remote Data Control (RDC), you can derive cell values using the Column object methods CellText and CellValue.
Example Title |
Copy Code
|
---|---|
Private Sub TDBList1_UnboundColumnFetch(Bookmark As Variant, _ ByVal Col As Integer, Value As Variant) Value = TDBList1.Columns(1).CellText(Bookmark) End Sub |
Note that these methods are not as efficient as using your own clone. This is because they always create a new clone (internal to the list), get the value, then destroy the clone. However, at times using CellText or CellValue may be preferable for the sake of simplicity.
Using a global clone can become complicated when the data control is refreshed frequently. Refreshing the data control rebuilds the Recordset, meaning that the data control's bookmarks are no longer the same as the bookmarks of the clone. Thus, re-cloning and re-establishing the field variables is necessary, or else the clone will continue to access the data of the old Recordset. As this may be a cumbersome process, you may find that the simplicity of CellText and CellValue is a workable alternative.
Finally, please note that CellText and CellValue cannot be used to retrieve the values of other unbound columns within the context of the UnboundColumnFetch event. Attempts to do so will always return an empty string (CellText) or Null (CellValue). The list has been designed this way to avoid infinite recursions of UnboundColumnFetch events when two unbound columns reference one another.