DatabaseField.BooleanValue

From Xojo Documentation

Revision as of 21:21, 23 January 2019 by PLefebvre (talk | contribs)
Property (As Boolean )
aDatabaseField.BooleanValue = newBooleanValue
or
BooleanValue = aDatabaseField.BooleanValue

Supported for all project types and targets.

Used to get and set the values of Boolean field types.

Notes

The values "0" and "False" are treated as False and "1" and "True" are treated as True. The behavior of any other values is undefined when retrieved using BooleanValue. Use StringValue to retrieve the original values in the field.

For situations where you need to set a database column to NULL, you should use the Value property like this:

rs.Edit
rs.Field("MyBooleanColumn").Value = Nil // sets to NULL in the database
rs.Update

Sample Code

Get the boolean value of a column in a RecordSet:

// rs is a RecordSet with a boolean column called "AllowEmails"
If rs.Field("AllowEmails").BooleanValue Then
MsgBox("Emails are allowed.")
End If

Set the boolean value of a column in a RecordSet:

// rs is a RecordSet with a boolean column called "AllowEmails":
rs.Edit
rs.Field("AllowEmails").BooleanValue = True
rs.Update