http://support.microsoft.com/kb/304274
Look for "Displaycontrol" property. Note it's VBA/VB6 code, and you may
additionally need to call
System.Runtime.InteropServices.Marshal.ReleaseComObject from VB.Net.
Armin
I've got it now, thanks Armin.
My main problem was that I needed to include "Microsoft DAO 3.6 Object
Library" into the .net references so that I can use the DAO routines.
Here is my solution for anyone interested (it looks for the column
requested and if it can't find it, creates a bool field/column and
adds the extra parameters using DAO routines to make the field/column
a checkbox):
Public Sub CreateColumn(ByVal ColumnName As String, ByVal
ConnectionString As String)
Dim objConn As New OleDb.OleDbConnection(ConnectionString)
objConn.Open()
'get info about the column
Dim schemaTable As DataTable =
objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, New Object()
{Nothing, Nothing, m_table_name, ColumnName})
'add the requested column if it does not exist
If schemaTable.Rows.Count = 0 Then
'create the new column
Dim Cmd As New OleDb.OleDbCommand(String.Format("ALTER TABLE
{0} ADD COLUMN {1} YesNo", m_table_name, ColumnName), objConn)
Cmd.ExecuteNonQuery()
Dim dbs As DAO.Database
Dim dbe As New DAO.DBEngine
Dim sDbPath As String = "C:\.....mdb"
Dim sDbPassword As String = ""
dbs = dbe.OpenDatabase(sDbPath, False, False, "MS
Access;PWD=" & sDbPassword & ";")
'make the new column a checkbox field (or else the field
displays as "-1" and "0" as "Yes/No")
Dim fld As DAO.Field
fld = dbs.TableDefs(m_table_name).Fields(ColumnName)
dbs.TableDefs(m_table_name).Fields(ColumnName).Properties.Append(fld.CreateProperty("DisplayControl",
DAO.DataTypeEnum.dbInteger, 106))
dbs.TableDefs(m_table_name).Fields(ColumnName).Properties.Append(fld.CreateProperty("Format",
DAO.DataTypeEnum.dbText, "Yes/No"))
dbs.Close()
'cleanup
dbs = Nothing
dbe = Nothing
fld = Nothing
End If
objConn.Close()
End Sub
Note: The "DisplayControl" and "Format" properties are used when
looking at the database in MSAccess