ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Set an Access field "not" required w/ADO (https://www.excelbanter.com/excel-programming/286551-set-access-field-not-required-w-ado.html)

raj

Set an Access field "not" required w/ADO
 
Please help if possible.

Does anyone know if it is possible to change a field
from "Required" to not-required after the table has been
constructed (but before data is added) using ADO from
Excel VBA?

My code follows. It produces RTE "-2147217887 (80040e21)
Multiple Step OLE DB operation generated errors...no work
was done."

If you know how to do this (or if it is possible any other
way i.e. using conventional VBA) please submit your
example code. I would be most appreciative. Thanks in
advance.

Function ADOAccessFieldNullable(argFullName As String,
argTableName As String)

Dim cat As New ADOX.Catalog
Dim tbl As ADOX.Table
Dim col As ADOX.Column
Dim cols As ADOX.Columns

cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;"
& "Data Source=" & argFullName & ";"
Set tbl = cat.Tables(argTableName)
Set cols = tbl.Columns
For Each col In cols
col.Attributes = adColNullable
Next col
cols.Refresh
Set cat = Nothing

End Function



All times are GMT +1. The time now is 05:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com