ModifyRec

Method
Modifies a record in a table.

Category
Records

 

Syntax
Function ModifyRec(ByVal hTable As Long, ByVal hRec As Long) As Boolean

hTable
The handle to the table.

hRec
The handle to the record that is to be modified. hRec itself does not change.

 

Example

'Case "ModifyRec"

'Modifies field #2 at table 18 in the first row

  CF1.OpenTable hTable, 18

  hRecord = CF1.AllocRec(hTable)

  CF1.BWT

  CF1.FindRec hTable, hRecord, "-"

  tmpVar2 = CF1.GetFieldData(hTable, hRecord, 2) '2=Name in customer table

  tmpVar = "Futte"

  CF1.AssignField hTable, hRecord, 2, tmpVar '2=Name in customer table

  tmpVar = CF1.ModifyRec(hTable, hRecord)

  CF1.EWT

  If VarType(tmpVar) = vbBoolean Then

  logWr "Modifyrec: OK"

  Else

  logWr "ModifyRec failed. It didn't return a boolean"

  End If

  CF1.BWT

  CF1.FindRec hTable, hRecord, "-"

  CF1.AssignField hTable, hRecord, 2, tmpVar2 '2=Name in customer table

  CF1.ModifyRec hTable, hRecord

  CF1.EWT

  logWr "Modifyrec: Undone the change"

  CF1.FreeRec hRecord

  CF1.CloseTable hTable

 

Comments
ModifyRec modifies a record in the table containing hRec. The record to be modified is the one identified by the values in the primary key fields in hRec. The current key and any filters that have been placed on the table handle have no effect on this operation.

In a multiuser environment, another application can modify the record in the table in the interval between your reading the record and your attempt to modify it. The C/SIDE database system automatically detects such an event, causing ModifyRec to raise an exception.

To prevent this from happening, use LockTable to lock the table before reading the record. Remember, however, that the table will be locked for the entire time that elapses between reading and modifying the record, and other users will therefore be unable to access it.

For more information about table locking, see the Application Designer’s Guide.

Note that the library does not support range and validity checks – it is your responsibility to verify that the data you are inserting is valid.

If the record is successfully modified, the function returns TRUE. If the record is not found in the table, two things can happen:

For more information about how errors are handled, see Error Handling.



© 2009 Microsoft Corporation. All rights reserved.