paulmcneil
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").C reatePrope rty("Displ ayControl" , 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").C reatePrope rty("Displ ayControl" , dbInteger, acCheckBox)
tdf.Fields(tf.Name).Proper ties.Appen d prp
Set prp = tdf.Fields("MyCheckbox").C
''''''''''''''''''''''''''
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",
End With
tdf.Fields.Refresh
Set tdf = db.TableDefs("trefLinkList
Set prp = tdf.Fields("MyCheckbox").C
tdf.Fields(tf.Name).Proper
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What version of access are you using?
Can you use this?
strSQL = "Alter Table tbl_Specs ADD COLUMN ["ColumnName"] YesNo"
CurrentDb.Execute strSQL
strSQL = "Alter Table tbl_Specs ADD COLUMN ["ColumnName"] YesNo"
CurrentDb.Execute strSQL
ASKER
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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I took your advice and now I get the data type mismatch on
Set prp = tdf.Fields("MyCheckbox").C