HOWTO: Displaying Boolean Values in Bound DataGridID: Q191717
|
An empty binary field formatted with rules to print text, such as "Yes" for True and "No" for False, will return an error unless nulls are allowed.
Option Explicit
Private rs As ADODB.Recordset
Private fmtBooleanData As StdDataFormat
Private Sub Form_Load()
Dim i As Integer
Set rs = New ADODB.Recordset
rs.Fields.Append "Field1", adBSTR, 64
rs.Fields.Append "BooleanField", adBoolean
rs.Open
rs.AddNew
rs.Fields("Field1").Value = "Field1"
rs.Fields("BooleanField").Value = True
rs.Update
For i = 1 To 5
rs.AddNew
rs.Update
Next i
rs.MoveFirst
Set DataGrid1.DataSource = rs
' set up Boolean Formatting
Set fmtBooleanData = New StdDataFormat
fmtBooleanData.Type = fmtBoolean
fmtBooleanData.TrueValue = "Yes"
fmtBooleanData.FalseValue = "No"
fmtBooleanData.NullValue = ""
Set DataGrid1.Columns(1).DataFormat = fmtBooleanData
End Sub
rs.Fields.Append "BooleanField", adBoolean
rs.Fields.Append "BooleanField", adBoolean, , adFldIsNullable
Additional query words: kbDSupport kbdse kbCtrl kbVBp600 kbVBp kbADO kbDatabase
Keywords :
Version :
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: June 9, 1999