John said:
Yes please, as I am upsizing back end to sql server.
Here's a procedure that would be passed the name of the table and apply your
requested properties to every boolean field:
'----- start of code -----
Sub SetBooleanProperties(TableName As String)
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Set db = CurrentDb
Set tdf = db.TableDefs(TableName)
For Each fld In tdf.Fields
If fld.Type = dbBoolean Then
fld.Required = True
fld.DefaultValue = 0
End If
Next fld
Set fld = Nothing
Set tdf = Nothing
Set db = Nothing
End Sub
'----- end of code -----
Error-handling is left up to you.
As written, this code would need to be run in the back-end. However, if you
want to run it in the front-end, it would be easy enough to open the db
object variable on the back-end database:
Set db = DBEngine.OpenDatabase("C:\Your\Path\To\YourBackEnd.mdb")
' ... rest of code ...
Set fld = Nothing
Set tdf = Nothing
db.Close
Set db = Nothing