Question : How to createa a checkbox datatype column in a table in VBA code

I have the following which alters the underlyitng temp table by adding a yes/no column.  But how do I tell the table that this new column is a checkbox?  The below creates a text box with 0 or 1, but even though the form that uses this field is a checkbox, it does not receive the check mark, it just stays blank when you click in it.  

strCollapseColumn = "ALTER TABLE tblTEMPSAPUPLOAD ADD COLUMN Collapse bit "

Answer : How to createa a checkbox datatype column in a table in VBA code


try this

CurrentDb.Execute "ALTER TABLE tblTEMPSAPUPLOAD ADD COLUMN Collapse YesNo"
Dim f1 As DAO.Field, pt As DAO.Property
Set f1 = CurrentDb.TableDefs("tblTEMPSAPUPLOAD").Fields("Collapse")
Set pt = f1.CreateProperty("DisplayControl", dbInteger, acCheckBox)
CurrentDb.TableDefs("tblTEMPSAPUPLOAD").Fields("Collapse").Properties.Append pt
Random Solutions  
 
programming4us programming4us