Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Community Wiki

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Navigation

Google Ads

Add a Display Control (Checkbox, Combobox) to a YesNo Field

From Wiki

Jump to: navigation, search

If you create a table with SQL, your YesNo fields will not be formatted. This may not bother you, but if it does, you will need to use DAO to add a format.

  1. Sub AddDisplayControl()
  2. 'Requires reference to Microsoft DAO 3.6 Object Library
  3. Dim tdf As DAO.TableDef
  4. Dim fld As DAO.Field
  5. Dim db As Database
  6. Dim strSQL As String
  7.  
  8.     Set db = CurrentDb
  9.    
  10.     'Create a table ...
  11.     strSQL = "Create Table tblLTD (TheYesNoCheck YesNo, TheYesNoCombo YesNo)"
  12.     db.Execute strSQL
  13.    
  14.     'It is now in the table collection, so ...
  15.     Set tdf = db.TableDefs("tblLTD")
  16.    
  17.     'Change the way the YesNo fields display.
  18.     'A Checkbox
  19.     Set fld = tdf.Fields("TheYesNoCheck")
  20.     Set prp = fld.CreateProperty("DisplayControl", dbInteger, acCheckBox)
  21.     fld.Properties.Append prp
  22.    
  23.     'A combobox
  24.     Set fld = tdf.Fields("TheYesNoCombo")
  25.     Set prp = fld.CreateProperty("DisplayControl", dbInteger, acComboBox)
  26.     fld.Properties.Append prp
  27.     'We will need a format
  28.     Set prp = fld.CreateProperty("Format", dbText, "Yes/No")
  29.     fld.Properties.Append prp
  30.  
  31. End Sub

558 Rating: 3.0/5 (4 votes cast)