I'm using VB6 with ADOX to check the properties of Access 97 table columns.
For the text fields it's important to prove that the field allows zero length or not.
The problem: the returned value is inverted.
If the field allows zero length the return is false, if the field doesn't the value is true.
If a field doesn't support this property it returns false, which is right.
Could someone explain why the return is inverted?
Private Sub ReadTableStructure()
Dim Cat As ADOX.Catalog
Dim Tbl As ADOX.Table
Dim Col As ADOX.Column
Set Cat = New ADOX.Catalog
Set Cat.ActiveConnection = Conn
For Each Tbl In Cat.Tables
For Each Col In Tbl.Columns
bAllowZeroLength = GetDBPropertyBool(Col.Properties, "Jet OLEDB:Allow Zero Length", True)
The Function GetDBPropertyBool:
Private Function GetDBPropertyBool(Properties As ADOX.Properties, sName As String, bDefaultValue As Boolean) As Boolean
Dim Prop As ADOX.Property
Set Prop = Properties(sName)
If Prop Is Nothing Then
GetDBPropertyBool = bDefaultValue
GetDBPropertyBool = Prop.Value
In Access this property is true, in the VB6 Object it's false.
I just found out that when i'm opening the table in Access in edit mode and just saving, the values which are given in VB6 are right. I don't change anything, just open to edit and save. Does anyone had already this problem?
Actually I don't found an answer, why I am getting these wrong values. To open and save every table is no solution for us and our customers.
I just found an workaround, by using DAO to read the property rightly.
Private Sub ReadTableStructure(DB As DAO.Database) Dim i As Integer, j As Integer Dim Fld As DAO.Field Dim tdfLoop As TableDef For i = 0 To DB.TableDefs.Count - 1 Set tdfLoop = DB(i) For j = 0 To tdfLoop.Fields.Count - 1 bAllowZeroLength = tdfLoop.Fields(j).AllowZeroLength Next j Next i End Sub
If someone got an answer, why ADO doesn't returns the right value, please let me know.