Access VBA How to change Required Field From Yes to No -


how can change tables's "required" property yes no?

the code below creating tables structure of table database:

sub copydatastrufromanodb_latebinding()       dim cn object     dim oldcat object     dim newcat object     dim oldtbl object     dim newtbl object     dim oldcol object     dim rst object     dim strtablename string       set oldcat = createobject("adox.catalog")     set newcat = createobject("adox.catalog")      set cn = createobject("adodb.connection")      cn.provider = "microsoft.ace.oledb.12.0"     cn.connectionstring = "data source=d:\nokia work\sudhir work (stc saudi)\data import\siran_dump_23jul2017_05_rc04_fdd.mdb;"     cn.open      newcat.activeconnection = currentproject.connection     oldcat.activeconnection = cn      set rst = createobject("adodb.recordset")      rst.open "tbl_appendtabledetails", currentproject.connection      while not rst.eof         strtablename = rst.fields(1)         each oldtbl in oldcat.tables             select case oldtbl.type                 case "table"                     if oldtbl.name = strtablename                         set newtbl = createobject("adox.table")                         newtbl                             .name = oldtbl.name & "_master"                             each oldcol in oldtbl.columns                                 .columns.append oldcol.name, oldcol.type, oldcol.definedsize                             next                         end                          on error resume next                             newcat.tables.delete strtablename & "_master"                         on error goto 0                         newcat.tables.append newtbl                         exit                     end if              end select         next         rst.movenext     loop     application.refreshdatabasewindow  end sub 

and code below altering each column's "nullable" property no yes, not working. giving me error message "multiple-step ole db operation generated errors. check each ole db status value, if available. no work done"

sub makenullable()      dim cat adox.catalog     dim tbl new adox.table     dim col new adox.column     set tbl = new adox.table      set cat = new adox.catalog     cat.activeconnection = currentproject.connection      each tbl in cat.tables         each col in tbl.columns             if col.properties("nullable") = false                 col.properties("nullable") = true             end if         next col      next tbl      set cat = nothing  end sub 


Comments