|
Write()
Changes the value of a database field.
Syntax
Write(<cField>,
<xData>, <lNoSafe>) --> lSuccess
Arguments
<cField> --> is the name of the field in
the selected database.
<xData> --> is the value to assign to
the given field. The data type of this expression must match the
data type of the designated database field.
<lNoSafe> --> should be passed as TRUE
to write data even in print preview mode. The default is FALSE.
Returns
Logical TRUE is returned if writing to the
database was successful. Otherwise logical FALSE if the write
attempt failed.
Description
This function is used to save or update
information stored in a database. It should be used with extreme
caution.
|
If misused this function can CORRUPT
the data contained in your accounting records. As such, it should
only be used by expert programmers.
|
The field name <cField> must exist in the
selected or designated database. The value <xData> must be of
the same type as the field referred to by <cField>. In other
words if <cField> refers to a character string, <xData>
must also be a character string.
It is not recommended to assume that a database
that has been opened is also currently selected. Therefore it is
advisable to always designate which database you are referring to
by using the alias operator. See the example below.
An attempt to write (update) a database may fail
if the contents of <xData> is not valid or appropriate or if
the record cannot be "locked". A record cannot be "locked" if that
same record is also being updated by another CAPITAL process or
application.
The Write() function is normally inactive during
print-previews. The form must be executed (send to a printer, disk
file or output to "none") before the Write() function will change
field data. This ensures that field data is not accidently changed
while you design your form. However, it is recommended that you
make a back-up of the original file while testing forms containing
Write() functions in order to be able to recover from mishaps.
Examples
The following assumes that the form has opened
the stock database. This changes the product description line in
the stock database to upper case:
Stock->(Write('Title',
Upper(Stock->Title)))
Notes
To read, instead of write, a field, specify the
database name followed by the -> symbols and then the field
name. For example:
Stock->Name
Custrec->Cusname
____________________________
Related Topics
Business
Function List
GetField()
|