- May 11, 2008
- 19,665
- 1,205
- 126
I am playing around with using a database and i want to write a script to change all the required properties from all the fields in the table as i want them. I want to set them as i would like them. Some need to be yes as they are required.
Others are optional and be set to required is no.
I can do this manually, but a macro or a script would be ideal to automate the process.
I have zero experience but i am a fast learner and i can always use the trial and error method and iterate to get something to function.
I found this site but i am still not clear what to do.
https://docs.microsoft.com/en-us/of...atabase-reference/field-required-property-dao
This example looks great to start from.
I have no idea to get it running in access.
Can someone show me the way to get this running and give me an example to change the required property from yes to no and vice versa ?
Thank you in advance.
Others are optional and be set to required is no.
I can do this manually, but a macro or a script would be ideal to automate the process.
I have zero experience but i am a fast learner and i can always use the trial and error method and iterate to get something to function.
I found this site but i am still not clear what to do.
https://docs.microsoft.com/en-us/of...atabase-reference/field-required-property-dao
This example looks great to start from.
I have no idea to get it running in access.
Code:
Sub RequiredX()
Dim dbsNorthwind As Database
Dim tdfloop As TableDef
Set dbsNorthwind = OpenDatabase("Northwind.mdb")
With dbsNorthwind
' Show which fields are required in the Fields
' collections of three different TableDef objects.
RequiredOutput .TableDefs("Categories")
RequiredOutput .TableDefs("Customers")
RequiredOutput .TableDefs("Employees")
.Close
End With
End Sub
Sub RequiredOutput(tdfTemp As TableDef)
Dim fldLoop As Field
' Enumerate Fields collection of the specified TableDef
' and show the Required property.
Debug.Print "Fields in " & tdfTemp.Name & ":"
For Each fldLoop In tdfTemp.Fields
Debug.Print , fldLoop.Name & ", Required = " & _
fldLoop.Required
Next fldLoop
End Sub
Can someone show me the way to get this running and give me an example to change the required property from yes to no and vice versa ?
Thank you in advance.