Link to home
Start Free TrialLog in
Avatar of paulmcneil
paulmcneilFlag for United States of America

asked on

Setting the Display Control property of a table field to Check Box

The following code is my attempt to set the Display Control property = "Check Box" for a table field named MyCheckBox which I am adding to the table trefLinkList. I get the error Data Type Mismatch on the line that is supposed to set the DisplayControl property:

 Set prp = tdf.Fields("MyCheckbox").CreateProperty("DisplayControl", dbInteger, acCheckBox)


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim db As Database
Dim tdf As TableDef, tf As Field
Dim prp As Property
 
 Set db = CurrentDb
 Set tdf = db.TableDefs("trefLinkList")
 
 With tdf
  .Fields.Append .CreateField("MyCheckbox", dbBoolean)
 End With
 
 tdf.Fields.Refresh
 Set tdf = db.TableDefs("trefLinkList")
 Set prp = tdf.Fields("MyCheckbox").CreateProperty("DisplayControl", dbInteger, acCheckBox)
 tdf.Fields(tf.Name).Properties.Append prp
ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of paulmcneil

ASKER

mbizup,
I took your advice and now I get the data type mismatch on

Set prp = tdf.Fields("MyCheckbox").CreateProperty("DisplayControl", dbInteger, acCheckBox)
What version of access are you using?
Can you use this?
 
        strSQL = "Alter Table tbl_Specs ADD COLUMN ["ColumnName"] YesNo"
        CurrentDb.Execute strSQL
I'm using Access 2003 SP2
Paul,

Thats the same version I'm using.  When something works on one machine but not another, the first thing I check is references (although I'd expect a different error message if it were a reference problem).  Anyhow to rule that out as a possibility, open a VBA module and go to Tools -> References.  Do you see anything flagged as MISSING?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial