PeterWallace
Programmer
I am trying to Make all the Text fields in a Table "ALLOW ZERO LENGTH"
This sample code is supposed to do just That
SOME TEXT COLS in the Table already allow Zero Length Some DO NOT
BUT ALL Text Columns on the Table report That COLUMN.Attribute = adColNullable ( I E 2 ) No Matter what ACCESS says
Sub ALLOWZEROLEN()
Dim Cat As ADOX.Catalog
Dim Table As ADOX.Table
Dim Mstr As String
Dim I As Integer
Set Cat = New ADOX.Catalog
Cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & TheDatabase & ";"
'TableExists = False
For Each Table In Cat.Tables
'Ok = True
Ok = False
Mstr = UCase$(Table.Name)
If Left(Mstr, 4) = "MSYS" Then Ok = False
If Mstr = "CREDITOR" Then Ok = True
If Ok = True Then
For I = 0 To Table.Columns.Count - 1
If Table.Columns(I).Type = adVarWChar Then
Debug.Print " Col "; Table.Columns(I).Name; " ";
Debug.Print " WAS attrib "; Table.Columns(I).Attributes;
If Table.Columns(I).Attributes = adColNullable Then
' thats whts wanted
Debug.Print
Else
Table.Columns(I).Attributes = adColNullable
Debug.Print " NOW attrib "; Table.Columns(I).Attributes, " adColNullable= "; adColNullable
End If
End If
Next
End If
Next
Set Cat = Nothing
End Sub