I have a table with several existing fields that we have required to have values in the past. Now, we want to remove that requirement. (In the mdb file, the fields "Required" property is True.) I want to make that property false by running VBA from our Excel (2007) front end. In the past, I've used ALTER TABLE (SQL) to make a field required but can't seem to do the reverse for some reason.
These fields are not part of a key. I don't see any related constraint, either. They are not indexed. They are text fields. As a test I've added a new field to the table (making it required using NOT NULL) but then could not remove the requirement using ALTER TABLE.
Set rsdata = New ADODB.Recordset
szSQL = "ALTER TABLE [strTableName] ALTER COLUMN [strFieldName] Text(50) NULL"
rsdata.Open szSQL, gDBconnect, adOpenStatic, adLockOptimistic, adCmdText
I'm finding only posts about making a field required, not removing the requirement. I can manually open mdb file and set the fields Required = false but I need to do this with code for multiple users/files. That is the problem.
Can someone please help with this?
Thanks in advance.
These fields are not part of a key. I don't see any related constraint, either. They are not indexed. They are text fields. As a test I've added a new field to the table (making it required using NOT NULL) but then could not remove the requirement using ALTER TABLE.
Set rsdata = New ADODB.Recordset
szSQL = "ALTER TABLE [strTableName] ALTER COLUMN [strFieldName] Text(50) NULL"
rsdata.Open szSQL, gDBconnect, adOpenStatic, adLockOptimistic, adCmdText
I'm finding only posts about making a field required, not removing the requirement. I can manually open mdb file and set the fields Required = false but I need to do this with code for multiple users/files. That is the problem.
Can someone please help with this?
Thanks in advance.